package com.chen.common.satoken.component;

import cn.dev33.satoken.stp.StpUtil;
import com.chen.base.inter.CurrUserInter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Component;

/**
 * @author: ~龙~
 * @date: 2023/8/15 16:53
 **/
@Component
@ConditionalOnMissingBean(CurrUserInter.class)
public class SaTokenSqlCurrUser implements CurrUserInter {

    @Override
    public String currUserId() {
        try {
            return StpUtil.isLogin() ? StpUtil.getLoginId().toString() : "0";
        }catch (Exception ignored){}
        return "0";
    }
}
